package com.workflow.workflowproject.listener;

import cn.dev33.satoken.stp.StpUtil;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.StringUtil;
import jakarta.annotation.PostConstruct;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngines;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 抄送节点触发监听
 */
@Component
public class CcTaskService implements JavaDelegate {

    @Autowired
    private ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

    private static CcTaskService ccTaskService;
    @PostConstruct
    public void init(){
        ccTaskService = this;
        ccTaskService.processEngine =this.processEngine;
    }

    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("触发抄送监听》》》》");
        //1、环境信息
        //流程任务ID
        String taskProcessId = execution.getId();
        System.out.println("流程任务ID:" + taskProcessId);
        //流程id
        String processInstanceId = execution.getProcessInstanceId();
        System.out.println("抄送流程ID:" + processInstanceId);
        //该任务 id
        String taskId = execution.getCurrentActivityId();
        System.out.println("抄送任务实例ID:" + taskId);
        //该任务名称
        String name  = execution.getEventName();
        System.out.println("抄送名称:" + name);

    }
}
